package org.groupg.practice;

import java.util.Random;

public class PreBody {
    private Double w;
    private Double b;
    private Double x;
    private Double y;
    private final double studyPad = 0.0005;

    public PreBody() {
        Random r = new Random();
        w = r.nextDouble();
        b = r.nextDouble();
    }
    public double insertParameter(Double parameter){
        y = w * parameter - b;
        this.x = parameter;
        return y;
    }

    public void backError(double E){
        double error  = (E - y) * studyPad;
        double subW = error * this.x; //w 的 误差
        double subB = -error;
        w = w + subW;
        b = b + subB;
    }
}
